package com.kusej.gitmanger.utils;

import com.google.common.collect.Maps;
import com.intellij.ide.util.PropertiesComponent;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;

import javax.swing.table.DefaultTableModel;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class Global {
    public static final String refHead = "refs/heads/";
    public static final String refTag = "refs/tags/";
    public static final String remoteFlag = "origin/";
    public static final String remoteDefault = "origin";
    public static final String masterDefault = "master";
    public static final String descTextFormat = "%s .from[%s]";
    public static final String tagNameFormat = "%s@tag%s";
    public static final String username = "git.manger.username";
    public static final String password = "git.manger.password";
    public static final String versionFlag = "git.manger.versionFlag";
    public static final Map<String, ObjectId> tagIdMap = Maps.newConcurrentMap();
    public static CredentialsProvider provider = null;

    public static void init() {
        String username = PropertiesComponent.getInstance().getValue(Global.username);
        String password = PropertiesComponent.getInstance().getValue(Global.password);
        if (username != null && password != null) {
            provider = new UsernamePasswordCredentialsProvider(username, password);  //生成身份信息
        }

    }
}
